package com.bcmusic.distri.service.impl;
import com.bcmusic.distri.dao.DistributeDetailMapper;
import com.bcmusic.distri.pojo.DistributeDetail;
import com.bcmusic.distri.service.DistributeDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/****
 * @Author:admin
 * @Description:DistributeDetail业务层接口实现类
 * @Date 2019/6/14 0:16
 *****/
@Service
public class DistributeDetailServiceImpl implements DistributeDetailService {

    @Autowired
    private DistributeDetailMapper distributeDetailMapper;





    /**
     * DistributeDetail构建查询对象
     * @param distributeDetail
     * @return
     */
    public Example createExample(DistributeDetail distributeDetail){
        Example example=new Example(DistributeDetail.class);
        Example.Criteria criteria = example.createCriteria();
        if(distributeDetail!=null){
            // 分发记录id。
            if(!StringUtils.isEmpty(distributeDetail.getDistributeDetailId())){
                    criteria.andEqualTo("distributeDetailId",distributeDetail.getDistributeDetailId());
            }
            //
            if(!StringUtils.isEmpty(distributeDetail.getConstractId())){
                    criteria.andEqualTo("constractId",distributeDetail.getConstractId());
            }
            // 音乐订单编号。关联order表的order_id字段。
            if(!StringUtils.isEmpty(distributeDetail.getOrderId())){
                    criteria.andEqualTo("orderId",distributeDetail.getOrderId());
            }
            // 分发商编号。关联distributor表的distributor_number字段。
            if(!StringUtils.isEmpty(distributeDetail.getDistributorNumber())){
                    criteria.andEqualTo("distributorNumber",distributeDetail.getDistributorNumber());
            }
            // 分发商获得的MB积分。即当被授权方通过分发商完成该订单时，分发商可获得的MB积分回馈。
            if(!StringUtils.isEmpty(distributeDetail.getOrderMbPoint())){
                    criteria.andEqualTo("orderMbPoint",distributeDetail.getOrderMbPoint());
            }
            //
            if(!StringUtils.isEmpty(distributeDetail.getCreateTime())){
                    criteria.andEqualTo("createTime",distributeDetail.getCreateTime());
            }
        }
        return example;
    }

}
